<template>
  <div class="download">
    <div class="download-title">
      <span class="iconfont icon-download">&#xe601;</span>
      <span>下载中心</span>
    </div>
    <div class="download-content">
      <div @click="download('健康中国行动纲领')">健康中国行动纲领</div>
      <div @click="download('全民健康宣传手册')">全民健康宣传手册</div>
    </div>
  </div>
</template>

<script>
import { Message } from "element-ui";
export default {
  name: "DownLoad",
  methods: {
    async download(fileName) {
      let listRes = await this.$api.searchManualList();
      if (listRes.code === 200) {
        if (listRes.rows.length >= 1) {
          let res = await this.$api.downloadByFile(fileName);
          if (res.code === 200) {
            if (res.total === 0) {
              Message({
                message: "文件丢失了，请联系工作人员",
                type: "error",
                duration: 1000,
              });
            } else {
              // let location = this.$api.BASEURL + res.rows[0].manualLocation;
              let list = res.rows[0].manualLocation.split(",");
              for (let item of list) {
                let location = this.$api.BASEURL + item;
                // console.log("location", location);
                window.open(location, "_blank");
              }
              // window.open(location, "_blank");
            }
          }
          // console.log(res);
        }
      }
    },
  },
};
</script>

<style scoped lang="less">
.download {
  padding-top: 10px;
  height: 250px;
  .icon-download {
    font-size: 20px;
    color: @themeColor;
    vertical-align: bottom;
  }
  .download-title {
    font-size: 18px;
    padding-bottom: 10px;
    border-bottom: 1px solid #d7d7d7;
  }
  .download-content {
    cursor: pointer;
    margin-top: 15px;
    div {
      margin-bottom: 10px;
      &:hover {
        color: @themeColor;
      }
    }
  }
}
</style>